package com.jingdianjichi.user.controller;

import com.jingdianjichi.Result;
import com.jingdianjichi.user.entity.dto.UserDto;
import com.jingdianjichi.user.entity.req.UserReq;
import com.jingdianjichi.user.service.UserService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户接口")
@RestController
@RequestMapping("/user")
public class UserContorller {

    private final UserService userService;


    @Autowired

    public UserContorller(UserService userService) {
        this.userService = userService;
    }

    @PostMapping ("/test")
    public Result adddUser(@RequestBody UserReq userReq) {

        UserDto userDto = new UserDto();
        BeanUtils.copyProperties(userReq, userDto);
        return Result.ok (userService.addUser(userDto));

    }
    @GetMapping("/ser")
    public String getser() {
        return "Hello, User!";
    }


}
